<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB R2019b"><title>Differential Drive</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: pre-wrap; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: 400; text-align: left;  }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;  }
.S2 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left;  }
.S3 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S4 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S5 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S6 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 16.996px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 16.996px;  }
.embeddedOutputsErrorElement {min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
.embeddedOutputsWarningElement{min-height: 18px; max-height: 250px; overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
.diagnosticMessage-wrapper {font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {color: rgb(255,100,0); text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {color: rgb(230,0,0); text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {white-space: pre-wrap;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {white-space: pre;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {white-space: pre; word-wrap: initial; min-height: 18px; max-height: 250px; overflow: auto;}
.textElement,.rtcDataTipElement .textElement {padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {min-height: 16px;}
.rightPaneElement .textElement {padding-top: 2px; padding-left: 9px;}</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Differential Drive</span></h1><div  class = 'S1'><span>Copyright 2018-2019 The MathWorks, Inc.</span></div><h2  class = 'S2'><span>Kinematic Model</span></h2><div  class = 'S1'><span>This vehicle has two independently driven wheels which can be used to control forward and angular velocity.</span></div><div  class = 'S1'><img class = "imageNode" src = "" width = "389" height = "343" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span style=' font-weight: bold;'>Inputs:</span></div><ul  class = 'S3'><li  class = 'S4'><span>Left and right wheel speeds </span><span texencoding="\omega_L" style="vertical-align:-6px"><img src="" width="20" height="19.5" /></span><span> and </span><span texencoding="\omega_R" style="vertical-align:-6px"><img src="" width="20" height="19.5" /></span><span>, in rad/s</span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Outputs</span></div><ul  class = 'S3'><li  class = 'S4'><span>Linear velocity </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);">v</span><span>, in m/s</span></li><li  class = 'S4'><span>Angular velocity </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);">ω</span><span>, in rad/s</span></li></ul><div  class = 'S1'><span style=' font-weight: bold;'>Forward Kinematics</span></div><div  class = 'S1'><span mathmlencoding="&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mfenced open=&quot;(&quot; close=&quot;)&quot;&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;+&lt;/mo&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;/mfenced&gt;&lt;mo stretchy=&quot;false&quot;&gt;,&lt;/mo&gt;&lt;mi&gt; &lt;/mi&gt;&lt;mi&gt; &lt;/mi&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mfenced open=&quot;(&quot; close=&quot;)&quot;&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;-&lt;/mo&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;/mrow&gt;&lt;/mfenced&gt;&lt;/mrow&gt;&lt;/math&gt;" style="vertical-align:-15px"><img src="" width="236.5" height="34" /></span></div><div  class = 'S1'><span style=' font-weight: bold;'>Inverse Kinematics</span></div><div  class = 'S1'><span mathmlencoding="&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot; display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mfenced open=&quot;(&quot; close=&quot;)&quot;&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;-&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;/mfenced&gt;&lt;mo stretchy=&quot;false&quot;&gt;,&lt;/mo&gt;&lt;mi&gt; &lt;/mi&gt;&lt;mi&gt; &lt;/mi&gt;&lt;mtext&gt;   &lt;/mtext&gt;&lt;msub&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;/msub&gt;&lt;mo stretchy=&quot;false&quot;&gt;=&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mn&gt;1&lt;/mn&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mi&gt;R&lt;/mi&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;mfenced open=&quot;(&quot; close=&quot;)&quot;&gt;&lt;mrow&gt;&lt;mi&gt;v&lt;/mi&gt;&lt;mo stretchy=&quot;false&quot;&gt;+&lt;/mo&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi&gt;ω&lt;/mi&gt;&lt;mi&gt;L&lt;/mi&gt;&lt;/mrow&gt;&lt;mrow&gt;&lt;mn&gt;2&lt;/mn&gt;&lt;/mrow&gt;&lt;/mfrac&gt;&lt;/mrow&gt;&lt;/mfenced&gt;&lt;/mrow&gt;&lt;/math&gt;" style="vertical-align:-15px"><img src="" width="238.5" height="34" /></span></div><h2  class = 'S2'><span>MATLAB Usage</span></h2><div  class = 'S1'><span>Create a </span><span style=' font-family: monospace;'>DifferentialDrive</span><span> object</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>R = 0.1; </span><span style="color: rgb(60, 118, 61);">% Wheel radius [m]</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>L = 0.5; </span><span style="color: rgb(60, 118, 61);">% Wheelbase [m]</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>vehicle = DifferentialDrive(R,L)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="ADA20BC2" data-testid="output_0" data-width="428" data-height="78" data-hashorizontaloverflow="false" style="width: 458px; max-height: 261px;"><div class="textElement"><div><span class="variableNameElement">vehicle = </span></div><div>  DifferentialDrive with properties:

    wheelRadius: 0.1000
      wheelBase: 0.5000</div></div></div></div></div></div><div  class = 'S1'><span>Solve forward kinematics</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>wL = 1;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>wR = -0.5;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>[v,w] = forwardKinematics(vehicle,wL,wR)</span></span></div><div  class = 'S8'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>v = 0.0250</div><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>w = -0.3000</div></div></div></div><div  class = 'S1'><span>Solve inverse kinematics</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S5'><span style="white-space: pre;"><span>vRef = 0.2;</span></span></div></div><div class="inlineWrapper"><div  class = 'S6'><span style="white-space: pre;"><span>wRef = 0.5;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>[wL,wR] = inverseKinematics(vehicle,vRef,wRef)</span></span></div><div  class = 'S8'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>wL = 0.7500</div><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>wR = 3.2500</div></div></div></div><div  class = 'S1'><span>Reference examples:</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:edit mrsDiffDriveDiscrete"><span>Discrete-time kinematic simulation</span></a></li><li  class = 'S4'><a href = "matlab:edit mrsDiffDriveContinuous"><span>Continuous-time kinematic simulation</span></a></li></ul><h2  class = 'S2'><span>Simulink Usage</span></h2><div  class = 'S1'><span>Simulink blocks are in the </span><span style=' font-weight: bold;'>Kinematic Models &gt; Differential Drive</span><span> section of the </span><a href = "matlab:mobileRoboticsLib"><span>block library</span></a><span>.</span></div><ul  class = 'S3'><li  class = 'S4'><span>Use the </span><span style=' font-weight: bold;'>Differential Drive Forward Kinematics</span><span> and </span><span style=' font-weight: bold;'>Differential Drive Inverse Kinematics</span><span> blocks to convert between body velocities and wheel velocities.</span></li><li  class = 'S4'><span>Use the </span><span style=' font-weight: bold;'>Differential Drive Simulation</span><span> block to simulate the pose given wheel speeds as inputs. You can configure the initial pose and simulation sample time.</span></li></ul><div  class = 'S1'><img class = "imageNode" src = "" width = "501" height = "265" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span>Reference examples:</span></div><ul  class = 'S3'><li  class = 'S4'><a href = "matlab:mrsDiffDriveModel"><span>Differential drive kinematic simulation</span></a></li></ul></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Differential Drive
% Copyright 2018-2019 The MathWorks, Inc.
%% Kinematic Model
% This vehicle has two independently driven wheels which can be used to control 
% forward and angular velocity.
% 
% 
% 
% *Inputs:*
%% 
% * Left and right wheel speeds $\omega_L$ and $\omega_R$, in rad/s
%% 
% *Outputs*
%% 
% * Linear velocity $v$, in m/s
% * Angular velocity $\omega$, in rad/s
%% 
% *Forward Kinematics*
% 
% $$v=\frac{R}{2}{\left(\omega_R +\omega_L \right)},\ \ \;\;\;\;\;\;\;\omega 
% =\frac{R}{L}{\left(\omega_R -\omega_L \right)}$$
% 
% *Inverse Kinematics*
% 
% $$\omega_L =\frac{1}{R}{\left(v-\frac{\omega L}{2}\right)},\ \ \;\;\;\omega_R 
% =\frac{1}{R}{\left(v+\frac{\omega L}{2}\right)}$$
%% MATLAB Usage
% Create a |DifferentialDrive| object

R = 0.1; % Wheel radius [m]
L = 0.5; % Wheelbase [m]
vehicle = DifferentialDrive(R,L)
%% 
% Solve forward kinematics

wL = 1;
wR = -0.5;
[v,w] = forwardKinematics(vehicle,wL,wR)
%% 
% Solve inverse kinematics

vRef = 0.2;
wRef = 0.5;
[wL,wR] = inverseKinematics(vehicle,vRef,wRef)
%% 
% Reference examples:
%% 
% * <matlab:edit mrsDiffDriveDiscrete Discrete-time kinematic simulation>
% * <matlab:edit mrsDiffDriveContinuous Continuous-time kinematic simulation>
%% Simulink Usage
% Simulink blocks are in the *Kinematic Models > Differential Drive* section 
% of the <matlab:mobileRoboticsLib block library>.
%% 
% * Use the *Differential Drive Forward Kinematics* and *Differential Drive 
% Inverse Kinematics* blocks to convert between body velocities and wheel velocities.
% * Use the *Differential Drive Simulation* block to simulate the pose given 
% wheel speeds as inputs. You can configure the initial pose and simulation sample 
% time.
%% 
% 
% 
% Reference examples:
%% 
% * <matlab:mrsDiffDriveModel Differential drive kinematic simulation>
##### SOURCE END #####
--></body></html>